Skip to content

fix(provenance): prefer canonical ds id when multiple IsDerivedFrom entries - #20

Merged
neuromechanist merged 1 commit into
feature/issue-1-epic-nemar-redesignfrom
feature/issue-19-provenance-canonical-pick
May 18, 2026
Merged

neuromechanist merged 1 commit into
feature/issue-1-epic-nemar-redesignfrom
feature/issue-19-provenance-canonical-pick

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #19

Summary

The provenance chip and OpenNeuro action-bar link on `/dataset/on002718` showed `ds000117` instead of the canonical `ds002718`. `metadata.json` lists both as `IsDerivedFrom` (the dataset was re-released on OpenNeuro under a new id) and the old loop locked onto whichever came first.

Fix

Collect all candidate matches into a list, then prefer the one whose extracted ds id matches the canonical on->ds swap (`on002718` -> `ds002718`). Fall back to first candidate when nothing matches, and to the id-swap-only path when there are no `IsDerivedFrom` entries at all (existing behavior preserved).

Tests

Two new tests in `provenance.test.ts`:

  • "prefers canonical ds when multiple IsDerivedFrom entries exist"
  • "falls back to first IsDerivedFrom when canonical is absent"

71/71 passing, typecheck 0 errors.

Verification on live data

`api.nemar.org/datasets/on002718` has `source_id: "ds002718"`. `data.nemar.org/on002718/metadata.json` has both `10.18112/openneuro.ds000117` (the historic id) and `10.18112/openneuro.ds002718.v1.1.0` (canonical) as `IsDerivedFrom`. Fix makes ds002718 win.

…ntries

Re-released OpenNeuro datasets carry both the original and the canonical
id as IsDerivedFrom in metadata.json. on002718 was originally released
as ds000117 then re-released as ds002718; both ids appear in
related_identifiers and the old loop locked onto whichever came first
with ??= (ds000117 in this case).

Collect candidate matches into a list, then prefer the one whose
extracted ds id matches the canonical on->ds swap. Fall back to first
candidate when nothing matches, and to the swap-only path when there
are no IsDerivedFrom entries at all (existing behavior).

Refs #19
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 18, 2026 •

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: a485d00
Status: ✅  Deploy successful!
Preview URL: https://ba88c1e1.nemar-website.pages.dev
Branch Preview URL: https://feature-issue-19-provenance.nemar-website.pages.dev

View logs

@neuromechanist
neuromechanist merged commit fcbdc88 into feature/issue-1-epic-nemar-redesign May 18, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-19-provenance-canonical-pick branch May 18, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant